package com.jian.java.controller;

import com.jian.java.bean.CommonResult;
import com.jian.java.bean.Payment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.List;

/**
 * @author Jiange
 * @create 2021-06-02-17:16
 */
@RestController
public class OrderController {
    @Autowired
    private RestTemplate restTemplate;

    @GetMapping("/all")
    public CommonResult all(){
        return restTemplate.getForObject("http://localhost:8001/payment/getall",CommonResult.class);
    }

    @GetMapping("/get/{id}")
    public CommonResult get(@PathVariable("id") int id){
        return restTemplate.getForObject("http://localhost:8001/payment/get/"+id,CommonResult.class);
    }

    @GetMapping("/port")
    public int getPort(){
        return restTemplate.getForObject("http://springcloud-payment/port",Integer.class);
    }
}
